package com.cnap.multiclouldmgmt.model.microSvc;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.Date;

/**
 * 内存使用的情况
 *
 * @author xc
 **/
@ApiModel(value = "com.cnap.multiclouldmgmt.model.microSvc.MemUseModel",description = "内存使用的情况")
public class GatewayLogModel {

    //svcId
    @ApiModelProperty(value = "svcId")
    private String svcId;

    //pod所属的svc的名称
    @ApiModelProperty(value = "服务名称")
    private String svcName;

    //startTime
    @ApiModelProperty(value = "开始时间")
    private Date startTime;

    //createTime
    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    //请求耗时，单位ms
    @ApiModelProperty(value = "请求耗时，单位ms")
    private int reqCost;


    //记录时间
    @ApiModelProperty(value = "记录时间tamp")
    private long createTimestamp;

    /**
     * get
     *
     * @return CreateTimestamp
     */
    public long getCreateTimestamp() {
        if (createTime != null) {
            createTimestamp = createTime.getTime();
        }
        return createTimestamp;
    }

    /**
     * set
     *
     * @param createTimestamp createTimestamp
     */
    public void setCreateTimestamp(long createTimestamp) {
        this.createTimestamp = createTimestamp;
    }

    /**
     * get
     *
     * @return ReqCost
     */
    public int getReqCost() {

        if ((reqCost == 0)
                &&(startTime != null)
                &&(createTime != null)){
            long startTimeStamp = startTime.getTime();
            long createTimeStamp = createTime.getTime();

            if (startTimeStamp > createTimeStamp){
                reqCost = (int)(startTimeStamp - createTimeStamp);
            }else {
                reqCost = (int)(createTimeStamp - startTimeStamp);
            }
        }

        return reqCost;
    }

    /**
     * set
     *
     * @param reqCost reqCost
     */
    public void setReqCost(int reqCost) {
        this.reqCost = reqCost;
    }

    /**
     * get
     *
     * @return SvcId
     */
    public String getSvcId() {
        return svcId;
    }

    /**
     * set
     *
     * @param svcId svcId
     */
    public void setSvcId(String svcId) {
        this.svcId = svcId;
    }

    /**
     * get
     *
     * @return SvcName
     */
    public String getSvcName() {
        return svcName;
    }

    /**
     * set
     *
     * @param svcName svcName
     */
    public void setSvcName(String svcName) {
        this.svcName = svcName;
    }

    /**
     * get
     *
     * @return StartTime
     */
    public Date getStartTime() {
        return startTime;
    }

    /**
     * set
     *
     * @param startTime startTime
     */
    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    /**
     * get
     *
     * @return CreateTime
     */
    public Date getCreateTime() {

        if ((createTime == null)&&(createTimestamp != 0L)){
            createTime = new Date(createTimestamp);
        }
        return createTime;
    }

    /**
     * set
     *
     * @param createTime createTime
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}
